<template>
	<view style="padding: 20rpx;">
		<view class="u-flex">
			<view style="font-size: 32rpx;">反馈标题：</view>
			<u-input placeholder="请输入反馈标题" border v-model="title"></u-input>
		</view>
		<view style="margin-top: 50rpx;">
			<view style="font-size: 32rpx;margin-bottom: 10rpx;">反馈内容：</view>
			<view style="position: relative;">
				<u-input placeholder="请输入反馈内容" border
				autoHeight type="textarea"height="400" maxlength="300"
				v-model="content"></u-input>
				<text style="position: absolute;right: 20rpx;bottom: 30rpx;"
				:class="content.length == 300?'malenth':''">{{content.length}}/300</text>
			</view>
		</view>
		<view style="justify-content: center;" class="u-flex">
			<view style="background-color: #fc6b2c; padding: 30rpx 30rpx;border-radius: 2em;
			font-weight: bold;color: #fffbef;width: 550rpx;text-align: center;margin: 50rpx 0;
			font-size: 29rpx;" @click="addClick">
				<text>提交</text>
			</view>
		</view>
		<!-- asdasd -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title:"",
				content:"",
				bookData:{},
				scr:""
			}
		},
		onLoad() {
			this.getbookData()
			
		},
		methods: {
			//
			async getbookData(){
				const res=await this.$myRequst({
					url:"/bookData/get/1"
				})
				this.bookData = res.data.data
				console.log(this.bookData)
				// /tomato-spring-boot/src/main/resources/static/images/0231e344d6ee4e2a8d90e6eaec17a066.png
				this.scr =this.$locality+this.bookData.imageUrl
				console.log(this.scr)
				//file:///C:/Users/Mr%20Huang/Desktop/springBoot-mybit/tomato-spring-boot/src/main/resources/static/images/0231e344d6ee4e2a8d90e6eaec17a066.png
				//file:///C:/Users/Mr%20Huang/Desktop/springBoot-mybit/tomato-spring-boot/src/main/resources/static/images/0231e344d6ee4e2a8d90e6eaec17a066.png
		},
			
			async addClick(){
				if(this.title == "" || this.content == ""){
					return uni.showToast({
						title:"反馈信息不能为空"
					})
				}
				const res=await this.$myRequst({
					url:"/feedback/post",
					method:"POST",
					data:{
						userId:uni.getStorageSync("userId"),
						title:this.title,
						content:this.content,
						feedbackTime:Date.now()
					}
				})
				if(res.data.code == 200){
					uni.showToast({
						title:"提交成功",
						icon:"none",
						position:"top",
						success: (res) => {
							setTimeout(()=>{
								uni.navigateBack({
									
								})
							},1000)
						}
					})
				}
			}
		}
	}
</script>

<style>
.malenth{
	color: red;
}
</style>
